package com.jy.controller;


import com.jy.config.CreatePerson;
import com.jy.config.GetPersonList;
import com.jy.entity.PageInfo;
import com.jy.entity.Proprietor;
import com.jy.entity.R;
import com.jy.service.IProprietorService;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.iai.v20200303.models.CreatePersonRequest;
import com.tencentcloudapi.iai.v20200303.models.GetPersonListRequest;
import com.tencentcloudapi.tci.v20190318.models.SubmitOpenClassTaskRequest;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;


/**
 * <p>
 * illustriousness.`t_proprietor` 前端控制器
 * </p>
 *
 * @author Null
 * @since 2022-11-14
 */
@RestController
@RequestMapping("/proprietor")
public class ProprietorController {

    @Resource
    private IProprietorService iProprietorService;

    //查询
    @PostMapping("/list")
    public R proplist(PageInfo pageInfo){
        PageInfo pageInfo1=iProprietorService.allprop(pageInfo);
        return R.result(pageInfo1);

    }
//删除
    @PostMapping("/deleteprop")
    public R detprop(Integer id){
        boolean bln=iProprietorService.deleteprop(id);
        if(!bln){
            return R.result(100,"删除失败");
        }
        return R.result();
    }
//    根据id查
    @PostMapping("/selectbyid")
    public R selectbyid(Integer id){
        Proprietor prop = iProprietorService.selectbyid(id);
        return R.result(prop);
    }
//    增
    @PostMapping("/addprop")
//    @RequestBody
    public R addprop(@RequestBody Proprietor proprietor){
//        boolean save = iProprietorService.save(proprietor);
        boolean bln=iProprietorService.addprop(proprietor);
        if(!bln){
            return R.result(100,"添加失败");
        }
        return R.result();
    }
//改
    @PostMapping("/updprop")
    public R updprop(@RequestBody Proprietor proprietor){
        boolean bln = iProprietorService.updprop(proprietor);
        if(!bln){
            return R.result(100,"修改失败");
        }
        return R.result();
    }
//查人员库
    @PostMapping("/facelist")
    public R facelist() throws TencentCloudSDKException {
        String get = GetPersonList.personnels();
        System.out.println(get);
        return R.result(get);
    }
//    添加人员
    @PostMapping("/createperson")
    public R createperson(String PersonName,String PersonId,Long Gender,String Image,Long UniquePersonControl) throws  TencentCloudSDKException{
        String create= CreatePerson.craeteperson(PersonName,PersonId,Gender,Image,UniquePersonControl);
        System.out.println(create);
        return R.result(create);
    }


}
